package com.tinchos.core.persistencia;

import com.tinchos.core.excepciones.PersistenceException;

public class DAOFactory {

	private String rutaBase;
	
	private static DAO getInstance(Class _class) throws PersistenceException {
	        
	        try {

	            DAO _dao = (DAO) _class.newInstance();                

	            return _dao;
	        }
	        catch (Exception _exception) {
	        	_exception.printStackTrace();
	        	throw new PersistenceException();
	        }
	                
	    }        

	    public static DAO getDAO(String _className) throws PersistenceException {

	        try {
	        	
	            return getInstance(Class.forName(_className));
	       
	        }
	        catch (ClassNotFoundException _exception) {
	        	_exception.printStackTrace();
	            throw new PersistenceException();
	        }                    
	    }
	    
	    public void setRutaBase(String rutaBase) {
			this.rutaBase = rutaBase;
		}
	    
	    public String getRutaBase() {
			return rutaBase;
		}
	    
}
